package com.fanhao.dllo.justforyou.fragment;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.fanhao.dllo.justforyou.R;
import com.fanhao.dllo.justforyou.activity.MyNoteActivity;
import com.fanhao.dllo.justforyou.activity.NotifyActivity;

public class YoursFragment extends Fragment implements View.OnClickListener {
    private ImageView imgIv;
    private TextView nameTv;
    private RelativeLayout notify,note;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

        View v = inflater.inflate(R.layout.fragment_yours,null);

        return v;

    }

    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);

        notify = (RelativeLayout)view.findViewById(R.id.notify);
        note = (RelativeLayout)view.findViewById(R.id.note);
        nameTv = (TextView)view.findViewById(R.id.nameTv);


    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        initView();
        getData();
    }

    private void initView() {

        notify.setOnClickListener(this);
        note.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.notify:
                Intent notifyintent = new Intent();
                notifyintent.setClass(getActivity(), NotifyActivity.class);
                getActivity().startActivity(notifyintent);

                break;

            case R.id.note:
                Intent noteintent = new Intent();
                noteintent.setClass(getActivity(),MyNoteActivity.class);
                getActivity().startActivity(noteintent);
                break;

        }
    }

    public void getData() {
       Intent intent =getActivity().getIntent();
        nameTv.setText(intent.getStringExtra("name"));
    }


}
